package com.ydy.controller;

import com.ydy.pojo.Stu;
import com.ydy.service.StuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

@RestController
@ApiIgnore //屏蔽接口和参数的展示
@Api(value = "Hello测试接口", tags = {"学生信息测试的相关接口"})
public class HelloController {

    @Autowired
    private StuService stuService;


    @GetMapping("/hello")
    public Object hello(){
        return "Hello Word ..";
    }

    @ApiOperation(value = "根据Id查询学生信息",notes = "根据Id查询学生信息",httpMethod = "GET")
    @GetMapping("/getStu/{id}")
    public Object getStu(
            @ApiParam(name = "id", value = "学生id", required = true)
            @PathVariable int id){
        Stu stu = stuService.getStu(id);
        return stu;
    }

    @PostMapping("/saveStu")
    public Object saveStu(){
        stuService.saveStu();
        return "ok";
    }

    @PostMapping("/updateStu")
    public Object updateStu(@PathVariable int id) {
        stuService.updateStu(id);
        return "OK";
    }
}
